package com.mac.hosp_pre.order.api;

import com.mac.hosp_pre.order.service.WeixinService;
import com.mac.hosp_pre.reply.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;


@Tag(name = "门户微信支付接口")
@RestController
@RequestMapping("/api/order/wx")
public class WeixinController {

    @Autowired
    private WeixinService weixinService;
    

    @Operation(description = "查询支付状态")
    @GetMapping("queryPayStatus/{outTradeNo}")
    public R queryPayStatus(@PathVariable String outTradeNo) {
        //调用微信接口实现支付状态查询
        return weixinService.queryPayStatus(outTradeNo);
    }

    @Operation(description = "生成微信支付二维码")
    @GetMapping("createNative/{outTradeNo}")
    public R createNative(@PathVariable String outTradeNo) {
        return weixinService.createNative(outTradeNo);
    }

    @Operation(description = "微信支付回调")
    @PostMapping("/payNotify")
    public String payNotify(HttpServletRequest request) {
        return weixinService.payNotify(request);
    }

    @Operation(description = "微信退款回调")
    @PostMapping("/refundNotify")
    public String refundNotify(HttpServletRequest request) {
        return weixinService.refundNotify(request);
    }


}
